import 'package:safetymonitor/generated/json/base/json_convert_content.dart';
import 'package:safetymonitor/app/data/entities/home/risk_tree_entity.dart';
import 'package:safetymonitor/app/data/entities/home/query_params_entity.dart';


RiskTreeEntity $RiskTreeEntityFromJson(Map<String, dynamic> json) {
  final RiskTreeEntity riskTreeEntity = RiskTreeEntity();
  final List<RiskTreeEntity>? children = (json['children'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<RiskTreeEntity>(e) as RiskTreeEntity).toList();
  if (children != null) {
    riskTreeEntity.children = children;
  }
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    riskTreeEntity.id = id;
  }
  final int? nodeId = jsonConvert.convert<int>(json['nodeId']);
  if (nodeId != null) {
    riskTreeEntity.nodeId = nodeId;
  }
  final int? nodeType = jsonConvert.convert<int>(json['nodeType']);
  if (nodeType != null) {
    riskTreeEntity.nodeType = nodeType;
  }
  final String? nodeName = jsonConvert.convert<String>(json['nodeName']);
  if (nodeName != null) {
    riskTreeEntity.nodeName = nodeName;
  }
  final bool? isExpand = jsonConvert.convert<bool>(json['isExpand']);
  if (isExpand != null) {
    riskTreeEntity.isExpand = isExpand;
  }
  final String? path = jsonConvert.convert<String>(json['path']);
  if (path != null) {
    riskTreeEntity.path = path;
  }
  final QueryParamsEntity? queryParams = jsonConvert.convert<QueryParamsEntity>(json['queryParams']);
  if (queryParams != null) {
    riskTreeEntity.queryParams = queryParams;
  }
  return riskTreeEntity;
}

Map<String, dynamic> $RiskTreeEntityToJson(RiskTreeEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['children'] = entity.children?.map((v) => v.toJson()).toList();
  data['id'] = entity.id;
  data['nodeId'] = entity.nodeId;
  data['nodeType'] = entity.nodeType;
  data['nodeName'] = entity.nodeName;
  data['isExpand'] = entity.isExpand;
  data['path'] = entity.path;
  data['queryParams'] = entity.queryParams?.toJson();
  return data;
}

extension RiskTreeEntityExtension on RiskTreeEntity {
  RiskTreeEntity copyWith({
    List<RiskTreeEntity>? children,
    int? id,
    int? nodeId,
    int? nodeType,
    String? nodeName,
    bool? isExpand,
    String? path,
    QueryParamsEntity? queryParams,
  }) {
    return RiskTreeEntity()
      ..children = children ?? this.children
      ..id = id ?? this.id
      ..nodeId = nodeId ?? this.nodeId
      ..nodeType = nodeType ?? this.nodeType
      ..nodeName = nodeName ?? this.nodeName
      ..isExpand = isExpand ?? this.isExpand
      ..path = path ?? this.path
      ..queryParams = queryParams ?? this.queryParams;
  }
}